package com.auxgroup.smarthome.business.service.inner;

import com.auxgroup.bridge.app.inner.vo.DeviceModelSimpleVo;
import com.auxgroup.smarthome.business.service.DeviceModelInfoInnerServiceFallback;
import com.auxgroup.smarthome.business.vo.DeviceModelInfoVo;
import com.auxgroup.smarthome.utils.PageContent;
import com.auxgroup.smarthome.web.ApiResponse;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * Created by niuGuangzhe on 2017/8/14.
 */
@FeignClient(name = "INNER-SERVICE", fallback = DeviceModelInfoInnerServiceFallback.class)
public interface DeviceModelInfoInnerService {

    /**
     * 新增型号
     * @param dto
     * @return
     */
    @RequestMapping(value = "/inner/model", method = RequestMethod.POST)
    ApiResponse addDeviceModelInfo(@RequestParam("model") String model,
                                   @RequestParam("modelItem") String modelItem,
                                   @RequestParam("deviceModelInfoDto") String dto);

    /**
     * 修改型号
     * @param dto
     * @return
     */
    @RequestMapping(value = "/inner/model", method = RequestMethod.PUT)
    ApiResponse updateDeviceModelInfo(@RequestParam("modelId") String modelId,
                                      @RequestParam("deviceModelInfoDto") String dto);

    /**
     * 根据设备名称查询型号详情
     * @param model
     * @return
     */
    @RequestMapping(value = "/inner/model", method = RequestMethod.GET)
    ApiResponse<DeviceModelInfoVo> getDetailDeviceModelInfo(@RequestParam("model") String model);

    /**
     * 根据型号主键查询型号详情
     * @param modelId
     * @return
     */
    @RequestMapping(value = "/inner/model_by_id",method = RequestMethod.GET)
    ApiResponse<DeviceModelInfoVo> getDeviceModelInfoByModelId(@RequestParam("modelId")String modelId);

    /**
     * 获取所有的型号信息
     * @return
     */
    @RequestMapping(value = "/inner/all_model",method = RequestMethod.GET)
    ApiResponse<List<DeviceModelSimpleVo>> getAllDeviceModelInfo();

    /**
     * 查询型号列表
     * @param model
     * @param modelItem
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "/inner/models", method = RequestMethod.GET)
    ApiResponse<PageContent<DeviceModelInfoVo>> getDetailDeviceModelInfos(@RequestParam("model") String model,
                                                                          @RequestParam("modelItem") String modelItem,
                                                                          @RequestParam("page") Integer page,
                                                                          @RequestParam("size") Integer size);

    /**
     * 删除型号
     * @param modelId
     * @return
     */
    @RequestMapping(value = "/inner/model",method = RequestMethod.DELETE)
    ApiResponse deleteDeviceModelInfo(@RequestParam("modelId")String modelId);


    /**
     * 根据关键字查询物料信息
     * @param keyword
     * @return
     */
    @RequestMapping(value = "/inner/model_items",method = RequestMethod.GET)
    ApiResponse getModelItemsByKeyword(@RequestParam("keyword") String keyword,@RequestParam("page") int page,@RequestParam("size") int size);

    @GetMapping(value = "/inner/is_exists_model_name")
    boolean isExistsModelName(String model);

}
